﻿using J.Model;
using J.ProductGet.Application.Command.ClassifiedManagementCommand;
using MediatR;
using SqlSugar;

namespace J.ProductGet.Application.CommandHandler.ClassifiedManagementCommandHandler
{
    public class ClassifiedManagementBackilCommandHandler : IRequestHandler<ClassifiedManagementBackilCommand, List<ClassifiedManagement>>
    {
        private readonly ISqlSugarClient _sqlSugarClient;
        public ClassifiedManagementBackilCommandHandler(ISqlSugarClient sqlSugarClient)
        {
            _sqlSugarClient = sqlSugarClient;
        }

        public async Task<List<ClassifiedManagement>> Handle(ClassifiedManagementBackilCommand request, CancellationToken cancellationToken)
        {
            return await _sqlSugarClient.Queryable<ClassifiedManagement>().Where(x => x.CategoryManagementID == request.CategoryManagementID).ToListAsync(); 
        }
    }
}
